import type { Module, ActionContext } from 'vuex'
import type { AxiosResponse } from 'axios'
import type { sendStateType } from './typings'
import { sendListGet, sendRemovePost, sendReadAllPost } from '~/api/system/send'

const work: Module<sendStateType, sendStateType> = {
  namespaced: true,
  state: {},
  getters: {},
  mutations: {},
  actions: {
    // 个人消息-列表
    async SendListGet<S, T>(_: ActionContext<S, T>, params: T) {
      return await sendListGet<T>(params).then((res: AxiosResponse) => res?.data)
    },
    // 删除个人消息-列表
    async SendRemovePost<S, T>(_: ActionContext<S, T>, params: T) {
      return await sendRemovePost<T>(params).then((res: AxiosResponse) => res?.data)
    },
    // 一键已读
    async SendReadAllPost<S, T>(_: ActionContext<S, T>, params: T) {
      return await sendReadAllPost<T>(params).then((res: AxiosResponse) => res?.data)
    }
  }
}

export default work
